package leetcode;

import java.util.Scanner;

/**
 * ClassName: XiechengT2
 * Package: leetcode
 * Description:
 *
 * @Author wjn
 * @Create 2025/9/6 14:45
 * @Version 1.0
 */
public class XiechengT2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        for (int i = 0; i < T; i++) {
            long a = scanner.nextLong();
            long b = scanner.nextLong();
            long c = scanner.nextLong();
            long d = scanner.nextLong();

            // 计算分子和分母
            long numerator = a * d + b * c;
            long denominator = b * d;

            // 如果分子为0，则是整数
            if (numerator == 0) {
                System.out.println("YES");
                continue;
            }

            // 计算最大公约数（GCD）
            long gcd = gcd(numerator, denominator);
            long simplifiedDenominator = denominator / gcd;

            // 检查简化后的分母是否只包含质因数2和5
            while (simplifiedDenominator % 2 == 0) {
                simplifiedDenominator /= 2;
            }
            while (simplifiedDenominator % 5 == 0) {
                simplifiedDenominator /= 5;
            }

            if (simplifiedDenominator == 1) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }

    // 计算最大公约数的辅助函数
    private static long gcd(long a, long b) {
        while (b != 0) {
            long temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
}
